<template>
    <div>
        <div>
            <el-select  v-model="query.college" placeholder="所属学院"  @change="collegeSelectChange(query.college)" style=" height: 36px;" size="small">
                <el-option
                    v-for="item in college"
                    :key="item.code"
                    :label="item.name"
                    :value="item.name">
                </el-option>
            </el-select>
            <el-select  v-model="query.organizationType" placeholder="机构类别"  @change="organizationTypeSelectChange(query.organizationType)"style=" height: 36px;"  size="small">
                <el-option
                    v-for="item in organizationType"
                    :key="item.code"
                    :label="item.name"
                    :value="item.name">
                </el-option>
            </el-select>
<!--            <el-select  v-model="query.achievementType" placeholder="成果类型"  @change="achievementTypeSelectChange(query.achievementType)" style=" height: 36px;" size="small">-->
<!--                <el-option-->
<!--                    v-for="item in achievementType"-->
<!--                    :key="item.code"-->
<!--                    :label="item.name"-->
<!--                    :value="item.name">-->
<!--                </el-option>-->
<!--            </el-select>-->
            <br/>
<!--            按钮-->
            <el-button size="small" type="primary" @click="handleQuery" v-auth code="account:organization:list">刷新列表</el-button>
            <el-button size="small" type="primary" @click="showAdd" v-auth code="account:organization:add">添加机构</el-button>
            <el-button size="small" type="primary" @click="showEdit"v-auth code="account:organization:update">编辑机构</el-button>
            <el-button size="small" type="primary" @click="showDetails"v-auth code="account:organization:detail">查看详情</el-button>
            <el-button size="small" type="danger" @click="showDelete"v-auth code="account:organization:delete">机构取消</el-button>
        </div>
        <br/>
        <el-table
            :data="tableData"
            stripe
            highlight-current-row
            @current-change="currentChange"
            style="width: 100%">
            <el-table-column
                prop="organizationName"
                label="机构名称" >
            </el-table-column>
            <el-table-column
                prop="principal"
                label="负责人">
            </el-table-column>
            <el-table-column
                prop="organizationType"
                label="机构类别">
            </el-table-column>
            <el-table-column
                prop="college"
                label="所属学院">
            </el-table-column>
            <el-table-column
                prop="phone"
                label="机构电话">
            </el-table-column>
            <el-table-column
                prop = "establishmentTime"
                label = "成立时间">
            </el-table-column>

        </el-table>


        <el-pagination class="pagination"
                       layout="prev, pager, next"
                       :total="totalCount" @current-change="handleCurrentChange">
        </el-pagination>
        <br/>

        <el-dialog title="添加机构" :visible.sync="addDialogVisible" width="90%">
            <template>
                <el-tabs v-model="activeName"  >
                    <el-tab-pane label="基础信息" name="first">
                        <el-form label-width="80px">
                            <el-row :gutter="10">
                                <el-col :span="12">
                                    <el-form-item label="机构名称" :error="errors.organizationName">
                                        <el-input v-model="form.organizationName" placeholder="请输入机构名称" ></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="负责人" :error="errors.principal">
                                        <el-input v-model="form.principal" placeholder="请输入负责人" ></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row :gutter="10">
                                <el-col :span="12">
                                    <el-form-item label="机构类别" :error="errors.organizationType">
                                        <el-select  v-model="form.organizationType"  placeholder="请选择机构级别"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in organizationType"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="所属学院" :error="errors.college">
                                        <el-select  v-model="form.college"  placeholder="请选择所属学院"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in college"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row :gutter="10">
                                <el-col :span="12">
                                    <el-form-item label="机构电话" :error="errors.phone">
                                        <el-input   type="textarea" autosize maxlength="100" 　placeholder="请输入机构电话"  v-model="form.phone" ></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="成立时间" :error="errors.establishmentTime">
                                        <div class="block">
                                            <el-date-picker
                                                v-model="form.establishmentTime"
                                                type="date"
                                                placeholder="选择日期">
                                            </el-date-picker>
                                        </div>
                                    </el-form-item>
                                </el-col>
                            </el-row>



                            <el-form-item>
                                <el-button type="primary" @click="handleSubmit">立即创建</el-button>
                                <el-button @click="addDialogVisible = false">取消</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>

                    <el-tab-pane label="机构成员" name="second">
                        <el-form :model="form.members" label-width="80px" class="demo-dynamic">
                            <el-form-item label-width="0px" v-for="(member,index) in form.members">
                                <el-row :gutter="10">
                                    <el-col :span="10">
                                        <el-input v-model="member.memberName" placeholder="成员名称"></el-input>
                                    </el-col>
                                    <el-col :span="10">
                                        <el-input v-model="member.phone" placeholder="成员电话"></el-input>
                                    </el-col>
                                    <el-col :span="2">
                                        <el-button @click.prevent="removeMember(member)">删除</el-button>
                                    </el-col>
                                </el-row>
                            </el-form-item>
                            <el-form-item>
                                <el-button @click="addmember()">新增成员</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>

                    <el-tab-pane label="机构科研成果" name="third">
                        <el-form :model="form.researchAchievements" label-width="80px" class="demo-dynamic">
                            <el-form-item label-width="0px" v-for="(researchAchievement,index) in form.researchAchievements">
                                <el-row :gutter="22">
                                    <el-col :span="6">
                                        <el-input v-model="researchAchievement.name"  placeholder="科研名" type="text"></el-input>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-select  v-model="researchAchievement.project"  placeholder="请选择科研项目"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in project"
                                                :key="item.name"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-col>
                                        <el-col :span="4">
                                                <el-select  v-model="researchAchievement.subject"  placeholder="请选择学科"  style="width:100%; height: 36px;">
                                                    <el-option
                                                        v-for="item in subject"
                                                        :key="item.code"
                                                        :label="item.name"
                                                        :value="item.name">
                                                    </el-option>

                                                </el-select>
                                        </el-col>
                                        <el-col :span="5">
                                                <el-select  v-model="researchAchievement.achievementType"  placeholder="请选择结果类型"   style="width:100%; height: 36px;">
                                                    <el-option
                                                        v-for="item in achievementType"
                                                        :key="item.code"
                                                        :label="item.name"
                                                        :value="item.name">
                                                    </el-option>
                                                </el-select>
                                        </el-col>

                                    <el-col :span="2">
                                        <el-button @click.prevent="removeFund(researchAchievement)">删除</el-button>
                                    </el-col>
                                </el-row>
                            </el-form-item>
                            <el-form-item>
                                <el-button @click="addFund()">新增科研成果</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>

                </el-tabs>
            </template>
        </el-dialog>


        <el-dialog title="编辑项目" :visible.sync="editDialogVisible" width="90%">
            <template>
                <el-tabs v-model="activeName"  >
                    <el-tab-pane label="基础信息" name="first">
                        <el-form label-width="80px">
                            <el-row :gutter="10">
                                <el-col :span="12">
                                    <el-form-item label="机构名称" :error="errors.organizationName">
                                        <el-input v-model="form.organizationName" placeholder="请输入机构名称" ></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="负责人" :error="errors.principal">
                                        <el-input v-model="form.principal" placeholder="请输入负责人" ></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row :gutter="10">
                                <el-col :span="12">
                                    <el-form-item label="机构类别" :error="errors.organizationType">
                                        <el-select  v-model="form.organizationType"  placeholder="请选择机构级别"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in organizationType"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="所属学院" :error="errors.college">
                                        <el-select  v-model="form.college"  placeholder="请选择所属学院"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in college"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>


                            <el-row :gutter="10">
                                <el-col :span="12">
                                    <el-form-item label="机构电话" :error="errors.phone">
                                        <el-input   type="textarea" autosize maxlength="100" 　placeholder="请输入机构电话"  v-model="form.phone" ></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="成立时间" :error="errors.establishmentTime">
                                        <div class="block">
                                            <el-date-picker
                                                v-model="form.establishmentTime"
                                                type="date"
                                                placeholder="选择日期">
                                            </el-date-picker>
                                        </div>
                                    </el-form-item>
                                </el-col>
                            </el-row>


                            <el-form-item>
                                <el-button type="primary" @click="handleSubmit">立即修改</el-button>
                                <el-button @click="editDialogVisible = false">取消</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>

                    <el-tab-pane label="机构成员" name="second">
                        <el-form :model="form.members" label-width="80px" class="demo-dynamic">
                            <el-form-item label-width="0px" v-for="(member,index) in form.members">
                                <el-row :gutter="10">
                                    <el-col :span="10">
                                        <el-input v-model="member.memberName" placeholder="成员名称"></el-input>
                                    </el-col>
                                    <el-col :span="10">
                                        <el-input v-model="member.phone" placeholder="成员电话"></el-input>
                                    </el-col>
                                    <el-col :span="2">
                                        <el-button @click.prevent="removeMember(member)">删除</el-button>
                                    </el-col>
                                </el-row>
                            </el-form-item>
                            <el-form-item>
                                <el-button @click="addmember()">新增成员</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>

                    <el-tab-pane label="机构科研成果" name="third">
                        <el-form :model="form.researchAchievements" label-width="80px" class="demo-dynamic">
                            <el-form-item label-width="0px" v-for="(researchAchievement,index) in form.researchAchievements">
                                <el-row :gutter="22">
                                    <el-col :span="6">
                                        <el-input v-model="researchAchievement.name"  placeholder="科研名" type="text"></el-input>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-select  v-model="researchAchievement.project"   placeholder="请选择科研项目"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in project"
                                                :key="item.name"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-col>
                                    <el-col :span="4">
                                        <el-select  v-model="researchAchievement.subject"  placeholder="请选择学科"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in subject"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>

                                        </el-select>
                                    </el-col>
                                    <el-col :span="5">
                                        <el-select  v-model="researchAchievement.achievementType"  placeholder="请选择结果类型"   style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in achievementType"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-col>

                                    <el-col :span="2">
                                        <el-button @click.prevent="removeFund(researchAchievement)">删除</el-button>
                                    </el-col>
                                </el-row>
                            </el-form-item>
                            <el-form-item>
                                <el-button @click="addFund()">新增科研成果</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>

                </el-tabs>
            </template>
        </el-dialog>


        <el-dialog title="项目详情" :visible.sync="detailDialogVisible" width="90%">
            <template>
                <el-tabs v-model="activeName"   >
                    <el-tab-pane label="基础信息" name="first">
                        <el-form label-width="80px">
                            <el-row :gutter="10">
                                <el-col :span="12">
                                    <el-form-item label="机构名称" :error="errors.organizationName">
                                        <el-input v-model="form.organizationName" disabled="disabled" placeholder="请输入机构名称" ></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="负责人" :error="errors.principal">
                                        <el-input v-model="form.principal" placeholder="请输入负责人" disabled="disabled" ></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row :gutter="10">
                                <el-col :span="12">
                                    <el-form-item label="机构类别" :error="errors.organizationType">
                                        <el-select  v-model="form.organizationType" disabled="disabled"  placeholder="请选择机构级别"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in organizationType"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="所属学院" :error="errors.college">
                                        <el-select  v-model="form.college"  disabled="disabled" placeholder="请选择所属学院"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in college"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>



                            <el-row :gutter="10">
                                <el-col :span="12">
                                    <el-form-item label="机构电话" :error="errors.phone">
                                        <el-input   type="textarea" autosize maxlength="100" disabled="disabled" 　placeholder="请输入机构电话"  v-model="form.phone" ></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="成立时间" :error="errors.establishmentTime">
                                        <div class="block">
                                            <el-date-picker disabled="disabled"
                                                v-model="form.establishmentTime"
                                                type="date"
                                                placeholder="选择日期">
                                            </el-date-picker>
                                        </div>
                                    </el-form-item>
                                </el-col>
                            </el-row>


                        </el-form>
                    </el-tab-pane>
                    <el-tab-pane label="机构成员" name="second">
                        <el-form :model="form.members" label-width="80px" class="demo-dynamic">
                            <el-form-item label-width="0px" v-for="(member,index) in form.members">
                                <el-row :gutter="10">
                                    <el-col :span="10">
                                        <el-input v-model="member.memberName" disabled="disabled" placeholder="成员名称"></el-input>
                                    </el-col>
                                    <el-col :span="10">
                                        <el-input v-model="member.phone" disabled="disabled" placeholder="成员电话"></el-input>
                                    </el-col>
<!--                                    <el-col :span="2">-->
<!--                                        <el-button @click.prevent="removeMember(member)">删除</el-button>-->
<!--                                    </el-col>-->
                                </el-row>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>

                    <el-tab-pane label="机构科研成果" name="third">
                        <el-form :model="form.funds" label-width="80px" class="demo-dynamic">
                            <el-form-item label-width="0px" v-for="(researchAchievement,index) in form.researchAchievements">
                                <el-row :gutter="22">
                                    <el-col :span="6">
                                        <el-input v-model="researchAchievement.subject"  disabled="disabled" placeholder="科研名" type="text"></el-input>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-select  v-model="researchAchievement.project" disabled="disabled"  placeholder="请选择科研项目"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in project"
                                                :key="item.name"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-col>
                                    <el-col :span="4">
                                        <el-select  v-model="researchAchievement.subject" disabled="disabled"  placeholder="请选择学科"  style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in subject"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>

                                        </el-select>
                                    </el-col>
                                    <el-col :span="5">
                                        <el-select  v-model="researchAchievement.achievementType"  disabled="disabled" placeholder="请选择结果类型"   style="width:100%; height: 36px;">
                                            <el-option
                                                v-for="item in achievementType"
                                                :key="item.code"
                                                :label="item.name"
                                                :value="item.name">
                                            </el-option>
                                        </el-select>
                                    </el-col>

                                </el-row>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>

                </el-tabs>
            </template>
        </el-dialog>
    </div>
</template>

<style>
.el-col {
    border-radius: 4px;
}
</style>

<script>
import Config from 'Config';
import ElDialog from "../../../../node_modules/element-ui/packages/dialog/src/component.vue";
import ElCol from "element-ui/packages/col/src/col";
import ElButton from "../../../../node_modules/element-ui/packages/button/src/button.vue";


export default {
    components: {
        ElButton,
        ElCol,
        ElDialog
    },


    data() {
        return {
            tableData: [],
            totalCount:0,
            query : {
            },
            activeName: 'first',
            form: {
            },
            errors:{
            },
            organizationType:{//机构类型
                code:'',
                name:''
            },organizationName:{//机构名称

            },
            college:{//所属学院
                code:'',
                name:''
            },
            achievementType:{//项目结果类型
                code:'',
                name:''
            },
            subject:{//学科
                code:'',
                name:''
            },
            project:{//科研项目
                name:''
            },
            researchAchievements:[{
                name:'',   //科研名称
                project:'',//科研项目
                subject:'',//学科
                type:''//结果类型
            }],
            multipleSelection: [],
            addDialogVisible: false,
            editDialogVisible: false,
            detailDialogVisible:false,
        }
    },
    created () {
        this.handleQuery();
        this.initSelect();
    },
    methods: {
        currentChange(currentRow, oldCurrentRow) {
            this.currentRow = currentRow;
        },
        handleSelectedNode(node) {
            this.selectedNode = node.id;
        },
        handleCurrentChange(page) {
            this.query.page = page;
            this.handleQuery();
        },

        //展示添加页面
        showAdd(){
            this.$objectUtils.clear(this.errors);
            this.$objectUtils.clear(this.form);
            this.form={
                members: [{
                    memberName:'',
                    phone:''
                }],
                researchAchievements:[{
                    subject:'',
                    number:''
                }]
            };
            this.activeName= 'first',
                this.addDialogVisible = true;
        },
        //展示详情
        showDetails(){
            if(this.currentRow != null) {
                this.$objectUtils.clear(this.errors);
                this.$objectUtils.clear(this.form);
                this.$axios.get(this.$config.SYSTEM_HOST + "/organization?id=" + this.currentRow.id).then((res) => {
                    this.$responseUtils.handlerError(res);
                    this.form = res.data.data;
                    this.activeName = 'first',
                        this.detailDialogVisible = true;
                });
            }else{
                this.$message.error("请先选择一个机构!");
            }
        },
        //展示修改页面
        showEdit() {
            if(this.currentRow != null) {
                if (this.currentRow.id!=null) {
                    console.log(this.currentRow);
                    // this.$objectUtils.clear(this.errors);
                    // this.$objectUtils.clear(this.form);
                    this.$axios.get(this.$config.SYSTEM_HOST + "/organization?id=" + this.currentRow.id).then((res) => {
                        this.$responseUtils.handlerError(res);
                        this.form = res.data.data;
                        this.activeName = 'first';
                        this.editDialogVisible = true;
                        //如果科研成果为空，初始化内容
                        if (res.data.data.researchAchievements == undefined){
                            console.log("科研成果为空，已初始化")
                            this.form.researchAchievements=[{
                                    name:'',
                                    project:'',
                                    subject:'',
                                    type:''
                                }]
                        }
                        //如果机构成员为空，初始化内容
                        if (res.data.data.members == undefined){
                            console.log("机构成员为空，已初始化")
                            this.form.members=[{
                                    memberName:'',
                                    phone:''
                                }]
                        }

                    });
                } else {
                    this.$message('该机构当前状态无法修改!');
                }
            }else{
                this.$message.error("请先选择一个机构!");
            }
        },
        //显示删除界面
        showDelete() {
            if(this.currentRow == null){
                this.$message.error("请先选择你要取消的机构!");
                return;
            }

            this.$confirm(<p>你确定要取消<span style="color: red;">{this.currentRow.name}</span>?</p>, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$axios.delete(this.$config.SYSTEM_HOST + "/organization?id=" + this.currentRow.id).then((res) => {
                    if(res.data.success){
                        this.$message('取消成功!');
                    }else{
                        this.$message.error(res.data.msg);
                    }
                    this.handleQuery();
                });
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        },
        //添加和修改
        handleSubmit() {
            this.$objectUtils.clear(this.errors);
            if(this.form.id){
                //修改
                this.$axios.put(this.$config.SYSTEM_HOST +"/organization",this.form).then((res) => {
                    if(res.data.success){
                        this.editDialogVisible = false;
                        this.updatePage();
                    }else{
                        this.$message.error(res.data.msg);
                    }
                }).catch((response) => {
                    if(this.$responseUtils.isBadRequest(response)){
                        this.errors = this.$responseUtils.getErrors(response);
                    }
                });
            }else{
                //添加
                this.$axios.post(this.$config.SYSTEM_HOST  +"/organization",this.form).then((res) => {
                    this.$responseUtils.handlerError(res);
                    this.addDialogVisible = false;
                    this.updatePage();
                }).catch((response) => {
                    if(this.$responseUtils.isBadRequest(response)){
                        //在这里处理验证错误
                        this.errors = this.$responseUtils.getErrors(response);
                    }
                });
            }
        },

        //刷新页面(有筛选条件)
        updatePage(){
            this.$axios.get(this.$config.SYSTEM_HOST + "/organization/query1" ).then((res) => {
                this.tableData = res.data.data.rows;
                this.totalCount = res.data.data.totalCount;
            });
        },
        //刷新页面(去除筛选条件)
        handleQuery(){
            this.$objectUtils.clear(this.query);
            this.$axios.get(this.$config.SYSTEM_HOST + "/organization/query1" ).then((res) => {
                this.tableData = res.data.data.rows;
                this.totalCount = res.data.data.totalCount;
            });
        },
        //加载下拉框【机构类型、所属学院、科研成果类型、学科、科研项目】
        initSelect(){
            //机构类型
            this.$axios.get(this.$config.SYSTEM_HOST + "/dict_type/query1?code=ORGANIZATION_TYPE").then((res) => {
                this.organizationType = res.data.data.rows[0].dataDictDetails;
            });
            //所属学院
            this.$axios.get(this.$config.SYSTEM_HOST + "/dict_type/query1?code=COLLEGE").then((res) => {
                this.college = res.data.data.rows[0].dataDictDetails;
            });
            //科研成果类型
            this.$axios.get(this.$config.SYSTEM_HOST + "/dict_type/query1?code=ACHIEVEMENTTYPE").then((res) => {
                this.achievementType = res.data.data.rows[0].dataDictDetails;
            });
            //学科
            this.$axios.get(this.$config.SYSTEM_HOST + "/dict_type/query1?code=SUBJECT").then((res) => {
                this.subject = res.data.data.rows[0].dataDictDetails;
            });
            //项目
            this.$axios.get(this.$config.SYSTEM_HOST + "/project/query1").then((res) => {
                this.project = res.data.data.rows;
            });
        },
        //选中事件
        organizationTypeSelectChange(selectedorganizationType){
            if(selectedorganizationType != '') {
                this.query.organizationType = selectedorganizationType;
                this.$axios.get(this.$config.SYSTEM_HOST + "/organization/query1" + this.$queryUtils.generateGetParameter(this.query)).then((res) => {
                    this.tableData = res.data.data.rows;
                    this.totalCount = res.data.data.totalCount;
                });
            }
        },
        //所属学院选中事件
        collegeSelectChange(selectedCollege){
            if(selectedCollege != '') {
                this.query.college = selectedCollege;
                this.$axios.get(this.$config.SYSTEM_HOST + "/organization/query1" + this.$queryUtils.generateGetParameter(this.query)).then((res) => {
                    this.tableData = res.data.data.rows;
                    this.totalCount = res.data.data.totalCount;
                });
            }
        },
        //成果类型选中事件
        achievementTypeSelectChange(selectedAchievementType){
            if(selectedAchievementType != '') {
                this.query.achievementType = selectedAchievementType;
                this.$axios.get(this.$config.SYSTEM_HOST + "/organization/query1" + this.$queryUtils.generateGetParameter(this.query)).then((res) => {
                    this.tableData = res.data.data.rows;
                    this.totalCount = res.data.data.totalCount;
                });
            }
        },
        //学科选中事件
        subjectSelectChange(selectedSubject){
            if(selectedSubject != '') {
                this.query.subject = selectedSubject;
                this.$axios.get(this.$config.SYSTEM_HOST + "/organization/query1" + this.$queryUtils.generateGetParameter(this.query)).then((res) => {
                    this.tableData = res.data.data.rows;
                    this.totalCount = res.data.data.totalCount;
                });
            }
        },
        //成员动态表单
        removeMember(member) {
            var index = this.form.members.indexOf(member)
            if (index !== -1) {
                this.form.members.splice(index, 1)
            }
        },
        addmember() {
            this.form.members.push({
                memberName:'',
                phone:'',
            });
        },
        //资金动态表单
        removeFund(fund) {
            var index = this.form.researchAchievements.indexOf(fund)
            if (index !== -1) {
                this.form.researchAchievements.splice(index, 1)
            }
        },
        //添加资金
        addFund() {
            this.form.researchAchievements.push({
                subject:'',
                number:''
            });
        },
        //翻页
        // handleCurrentChange(page) {
        //     this.query.page = page;
        //     this.handleQuery();
        // }
    }
}
</script>

